<?php
namespace Mob\Model;
use Think\Model;
class UserBankModel extends Model
{
    
    
    protected $_auto = array (
        array('createdate','date',1,'function',array('Y-m-d H:i:s')), // 对create_time字段在插入的时候写入当前时间
    );
     protected $_validate = array(
        array('uid','require','用户ID不能为空！'),
    );
     
     /**
      * 插入收款账号
      * @param unknown $arry
      * @return number|unknown
      */
	public function inst($arry)
	{
	    foreach ($arry as $key => $value){
	        $data[$key] = $value;
	    };
	    $result["status"]=0;
	    if (!$this->create($data)){
	        $result["mess"]=$this->getError();
	    }else{
	        $result = $this->add(); // 写入数据到数据库 
            if($result){
                $result["status"]=1;
                $result["msg"]="保存成功！";
            }
	    };
	    return $result;
	}
	/**
	 * 条件查询收款账号
	 * @param unknown $arry
	 */
	public function get($arry)
	{
	    foreach ($arry as $key => $value){
	        $condition[$key] = $value;
	    };
        return $this->field(true)->where($condition)->order('id desc')->find();
	}
	
	
	public function getCount($arry)
	{
	    foreach ($arry as $key => $value){
	        $condition[$key] = $value;
	    };
	    return $this->where($condition)->count();
	}
}
?>